package com.example.activitybasic;

import androidx.appcompat.app.AppCompatActivity;

import android.content.Intent;
import android.os.Bundle;
import android.view.View;

public class MainActivity extends AppCompatActivity implements View.OnClickListener {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        findViewById(R.id.start).setOnClickListener(this);
        findViewById(R.id.finish).setOnClickListener(this);
    }

    @Override
    public void onClick(View v) {
        if (v.getId() == R.id.start) {  //开启Activity的按钮
            Intent intent = new Intent(MainActivity.this, ActivityExample.class);
            startActivity(intent);
        } else if (v.getId() == R.id.finish) {  //关闭Activity的按钮
            finish();
        }

    }
}